<%@page import="com.joinhawaii.admin.sales.SalesDAO"%>
<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/home/include/init_home.jsp" %>
<%

	HashList code102	= CommonUtil.getCodeList("102");	//성별
	HashList code118	= CommonUtil.getCodeList("118");	//여행인원
	HashList codeEnjoy	= CommonUtil.getCodeList("enjoy", "");	//선택관광
	HashList codeCar	= CommonUtil.getCodeList("car", "");	//렌터카


	String req_id			= StringUtil.nvl(request.getParameter("req_id"));
	String curr_page		= StringUtil.nvl(request.getParameter("curr_page"));


	HashMap infos = new HashMap();
	infos.put("req_id",	req_id);


	SalesDAO dao 			= new SalesDAO();
	HashList list 			= dao.selectReqList(infos);		//바로예야
	HashList hotelList 		= dao.selectReqHotelList(infos);	//
	HashList customerList 	= dao.selectReqCustomerList(infos);	//
	HashList enjoyList 		= dao.selectReqEnjoyList(infos);	//
	HashList carList 		= dao.selectReqCarList(infos);	//
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%= HOME_NAME %></title>
<link href="../css/home.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="/css/smoothness/jquery-ui-1.8.17.custom.css" media="screen" />
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.18.custom.min.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/jquery.maskedinput-1.3.min.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/jquery.ui.datepicker-ko.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/common2.js" charset="utf-8"></script>
<script>
	$(document).ready(function() {


		$('input[name="start_dt"]').mask('9999.99.99').datepicker();
		$('input[name="end_dt"]').mask('9999.99.99').datepicker();

		$('input[name="enjoy.start_dt"]').mask('9999.99.99').datepicker();
		$('input[name="car.start_dt"]').mask('9999.99.99').datepicker();

		$('input[name="hotel.start_dt"]').mask('9999.99.99').datepicker();
		$('input[name="hotel.end_dt"]').mask('9999.99.99').datepicker();

		$('select:[name="enjoy.enjoy_id"]').live('change', function() {
			var oPrice = $(this).closest('tr').find('select[name="enjoy.price_id"]');
			//alert($(this).val())
			$.ajax({
				url: '/common/selectCode.do',
				type: "POST",
			    dataType: 'json',//html,text,json
			    data: { //파라미터
			    	code_gubn : 'price',
			    	enjoy_id : $(this).val()
			    },
			    error: function(data, status, err){
			    	alert(err);
			    },
				success: function(data){
					oPrice.find('option').remove();
					if (data.list.length > 0) {
						for (var i = 0; i < data.list.length; i++) {
							oPrice.append('<option value="' + data.list[i].code + '">'+data.list[i].code_name+'</option>');
						}
					} else {
						oPrice.append('<option value=""></option>');
					}
			    }
			});
		});

	});

	function fnAddEnjoy() {
		var txt = '<tr><th align="center" class="customer_bg">상품명</th>'
            	+ '<td colspan="3" class="customer_bg2">'
            	+ '<select name="enjoy.enjoy_id" style="width:360px">'
				+ '<%= StringUtil.makeOptionByGroup(codeEnjoy, "") %>'
				+ '</select> '
				+ '<select name="enjoy.price_id" style="width:200px"><option value=""></option></select>'
				+ '</td>'
				+ '</tr>'
				+ '<tr>'
				+ '<td colspan="4" class="customer_line_01"></td>'
				+ '</tr>'
				+ '<tr>'
				+ '<th align="center" class="customer_bg">여행일정</th>'
				+ '<td class="customer_bg2"><input type="text" name="enjoy.start_dt" size="5" style="width:100px;" class="input2 c" /></td>'
				+ '<th align="center" class="customer_bg">여행인원</th>'
				+ '<td class="customer_bg2">'
				+ '<select name="enjoy.adult_count" style="width:66px">'
				+ '<option value="0">성인</option>'
				+ '<%= StringUtil.makeOption(code118, "") %>'
				+ '</select> '
				+ '<select name="enjoy.child_count" style="width:66px">'
				+ '<option value="0">소아</option>'
				+ '<%= StringUtil.makeOption(code118, "") %>'
				+ '</select> '
				+ '<select name="enjoy.baby_count" style="width:66px">'
				+ '<option value="0">유아</option>'
				+ '<%= StringUtil.makeOption(code118, "") %>'
				+ '</select>'
				+ '</td>'
				+ '</tr>'
				+ '<tr>'
				+ '<td colspan="4" bgcolor="#999999"></td>'
				+ '</tr>' ;

		$("#enjoyList").append(txt);
		$('input[name="enjoy.start_dt"]').mask('9999.99.99').datepicker();
	}

	function fnAddCar() {
		var txt = '<tr>'
				+ '<td colspan="4" class="customer_line_01"></td>'
				+ '</tr>'
      			+ '<tr>'
      			+ '<th align="center" class="customer_bg">차종</th>'
      			+ '<td class="customer_bg2">'
      			+ '<select name="car.car_id" style="width:160px">'
				+ '<%= StringUtil.makeOption(codeCar, "") %>'
				+ '</select>'
				+ '</td>'
				+ '<th align="center" class="customer_bg">대여일자</th>'
				+ '<td class="customer_bg2">'
				+ '<input type="text" name="car.start_dt" size="5" style="width:100px;" class="input2 c" /> '
				+ '<input type="text" name="car.rent_day" size="5" style="width:60px;" class="input2" />일'
				+ '</td>'
				+ '</tr>';

		$("#carList").append(txt);
		$('input[name="car.start_dt"]').mask('9999.99.99').datepicker();
	}

	function fnAddHotel() {
		var txt = '<div style="margin-top:4px; margin-bottom:4px">호텔명 &nbsp;&nbsp; : <input type="text" name="hotel.hotel_name" style="width:200px;" class="input2" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '
				+ '숙박기간 : <input type="text" name="hotel.start_dt" style="width:80px;" class="input2" /> '
				+ ' ~ <input type="text" name="hotel.end_dt" style="width:80px;" class="input2" /></div>';
		$("#hotelList").append(txt);
		$('input[name="hotel.start_dt"]').mask('9999.99.99').datepicker();
		$('input[name="hotel.end_dt"]').mask('9999.99.99').datepicker();
	}

	function fnDelHotel(oObj) {
		$(oObj).closest('div').remove();
	}

	function fnAddCustomer() {
		var txt = '<div style="margin-top:4px; margin-bottom:4px">성함 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : <input type="text" name="customer.customer_name" style="width:55px;" class="input2" /> &nbsp; '
				+ '영문 : <input type="text" name="customer.customer_eng_name" style="width:120px;" class="input2" /> &nbsp;&nbsp; '
				+ '생년월일 : <input type="text" name="customer.birth_date" style="width:80px;" class="input2" /> &nbsp; '
				+ '성별 : <select name="customer.gender" style="width:50px"><%= StringUtil.makeOption(code102, "") %></select></div> ';
		$("#customerList").append(txt);
	}

	function fnDelCustomer(oObj) {
		$(oObj).closest('div').remove();
	}


	function fnSaveReq(jobType) {
		if (jobType == "D") {
			if (confirm("삭제하시겠습니까?")) {
				document.reqForm.job_type.value = jobType;
				document.reqForm.submit();
			}
		}
		else {
			if (cfCheckNull(document.reqForm.start_dt, "전체일정을 입력해주세요")
				|| cfCheckNull(document.reqForm.end_dt, "전체일정을 입력해주세요")
				|| cfCheckNull(document.reqForm.start_air_name, "출발편명을 입력해주세요")
				|| cfCheckNull(document.reqForm.return_air_name, "귀국편명을 입력해주세요")
				|| cfCheckNull(document.reqForm.customer_name, "작성자를 입력해주세요")
				|| cfCheckNull(document.reqForm.phone_no, "연락처를 입력해주세요"))
			{
				return false;
			}

			document.reqForm.job_type.value = jobType;
			document.reqForm.submit();
		}
	}

</script>
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <%@ include file="/home/include/top_menu.jsp" %>
  <tr>
    <td valign="top" align="center" class="sub_con"><table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
      <!-- 좌측 네비 시작-->
        <%@ include file="/home/include/left_menu.jsp" %>
        <!-- 좌측 네비 끝-->
        <td width="50"></td>
        <!-- 컨텐츠 시작-->
        <td valign="top" align="left"><table width="723" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="70%"><img src="../images/sub/09_title_01.gif" alt="고객센터" width="101" height="31" /><img src="../images/sub/09_title_sub.gif" width="272" height="18" /></td>
                <td width="30%" align="right" valign="bottom"></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td height="5"><img src="../images/sub/sub_line.gif" width="723" height="5" /></td>
          </tr>
          <tr>
            <td height="30"></td>
          </tr>
          <tr>
            <td class="sub_title">선택관광/렌터카 바로예약</td>
          </tr>
          <tr>
                <td height="30"></td>
          </tr>
          <!--입력폼 시작-->
          <tr>
            <td height="30">
            	<form name="reqForm" action="./reserveSave.do" method="post">
				<input type="hidden" name="job_type" value="U"/>
				<input type="hidden" name="req_id" value="<%= req_id %>"/>
            	<input type="hidden" name="pmenu_id" value="<%= pmenu_id %>"/>
            	<input type="hidden" name="menu_id" value="<%= menu_id %>"/>
            	<table width="100%" border="0" cellspacing="0" cellpadding="0">

			<!--기본정보 시작-->
				  <tr>
					<td height="34">
						<img src="../images/sub/customer_02_t_005.gif" alt="기본정보"  align="absmiddle"/>(* 필수입력 항목입니다.)
					</td>
				  </tr>
				  <tr>
					<td height="2" bgcolor="#999999"></td>
				  </tr>
				  <tr>
					<td class="customer_line_01"></td>
				  </tr>
				  <tr>
					<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
						<colgroup>
							<col width="100"/>
							<col />
						</colgroup>
					  <tr>
						<th align="center" class="customer_bg">전체일정*</th>
						<td class="customer_bg2" colspan="3">
							한국출발일 : <input type="text" name="start_dt" value="<%=StringUtil.toDate(list.get("start_dt",0),".") %>" style="width:100px;" class="input2 c" />
							~
							한국도착일 : <input type="text" name="end_dt" value="<%=StringUtil.toDate(list.get("end_dt",0),".") %>" style="width:100px;" class="input2 c" />
						</td>
					  </tr>
					  <tr>
						<td colspan="4" class="customer_line_01"></td>
					  </tr>
					  <tr>
						<th align="center" class="customer_bg">국제선*</th>
						<td class="customer_bg2" colspan="3">
							출발편명 :
							<input type="text" name="start_air_name" value="<%= list.get("start_air_name",0) %>" style="width:200px;" class="input2" />
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							귀국편명 :
							<input type="text" name="return_air_name" value="<%= list.get("return_air_name",0) %>" style="width:200px;" class="input2" />
						</td>
					  </tr>
					  <tr>
						<td colspan="4" class="customer_line_01"></td>
					  </tr>
					  <tr>
						<th align="center" class="customer_bg">숙박호텔*</th>
						<td class="customer_bg2" colspan="3" id="hotelList">
					<%	for (int i = 0; i < hotelList.size(); i++) { %>
							<div style="margin-top:4px;">
								호텔명 &nbsp;&nbsp; :
								<input type="text" name="hotel.hotel_name" value="<%=hotelList.get("hotel_name",i) %>" style="width:200px;" class="input2" align="absmiddle"/>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								숙박기간 :
								<input type="text" name="hotel.start_dt" value="<%=hotelList.get("start_dt",i) %>" style="width:80px;" class="input2 c" align="absmiddle" />
								~
								<input type="text" name="hotel.end_dt" value="<%=hotelList.get("end_dt",i) %>" style="width:80px;" class="input2 c"  align="absmiddle"/>
								<a href="#nohref" onclick="fnDelHotel(this)"><img src="../images/sub/btn_minus.gif" align="absmiddle"></a>
							</div>
					<%	} %>
							<div style="margin-top:4px; margin-bottom:4px">
								호텔명 &nbsp;&nbsp; :
								<input type="text" name="hotel.hotel_name" value="" style="width:200px;" class="input2" align="absmiddle"/>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								숙박기간 :
								<input type="text" name="hotel.start_dt" value="" style="width:80px;" class="input2 c" align="absmiddle" />
								~
								<input type="text" name="hotel.end_dt" value="" style="width:80px;" class="input2 c"  align="absmiddle"/>
								<a href="#nohref" onclick="fnAddHotel()"><img src="../images/sub/btn_plus.gif" align="absmiddle"></a>
							</div>
						</td>
					  </tr>
					  <tr>
						<td colspan="4" class="customer_line_01"></td>
					  </tr>
					  <tr>
						<th align="center" class="customer_bg">여행자정보*</th>
						<td colspan="3" class="customer_bg2" style="padding-left:20px" id="customerList">
					<%	for (int i = 0; i < customerList.size(); i++) { %>
							<div style="margin-top:4px;">
								한글성함 : <input type="text" name="customer.customer_name" value="<%= customerList.get("customer_name",i) %>" style="width:55px;" class="input2" /> &nbsp;
								영문성함 : <input type="text" name="customer.customer_eng_name" value="<%= customerList.get("customer_eng_name",i) %>" style="width:95px;" class="input2" /> &nbsp;&nbsp;
								생년월일 : <input type="text" name="customer.birth_date"  value="<%= customerList.get("birth_date",i) %>" style="width:80px;" class="input2" /> &nbsp;
								성별 : <select name="customer.gender" id="customer.gender" style="width:50px">
										<%= StringUtil.makeOption(code102, customerList.get("gender",i)) %>
										</select>
									<a href="#nohref" onclick="fnDelCustomer(this)"><img src="../images/sub/btn_minus.gif" align="absmiddle"></a>
							</div>
					<%	} %>
							<div style="margin-top:4px; margin-bottom:4px">
								성함 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : <input type="text" name="customer.customer_name" id="customer.customer_name" style="width:55px;" class="input2" /> &nbsp;
								영문 : <input type="text" name="customer.customer_eng_name" id="customer.customer_eng_name" style="width:120px;" class="input2" /> &nbsp;&nbsp;
								생년월일 : <input type="text" name="customer.birth_date" id="customer.birth_date" style="width:80px;" class="input2" /> &nbsp;
								성별 : <select name="customer.gender" id="customer.gender" style="width:50px">
										<%= StringUtil.makeOption(code102, "") %>
										</select>
									<a href="#nohref" onclick="fnAddCustomer()"><img src="../images/sub/btn_plus.gif" align="absmiddle"></a>
							</div>
						</td>
					  </tr>
					  <tr>
						<td colspan="4" class="customer_line_01"></td>
					  </tr>
                </table></td>
              </tr>

              <!--기본정보 끝-->
              <tr>
              	<td height="36"></td>
              </tr>

              <!--선택관광 시작-->
              <tr>
                <td height="34"><img src="../images/sub/customer_02_t_002.gif" alt="선택관광" width="96" height="26" /></td>
              </tr>
              <tr>
                <td height="2" bgcolor="#999999"></td>
              </tr>
              <tr>
                <td><table id="enjoyList" width="100%" border="0" cellspacing="0" cellpadding="0">
                	<colgroup>
				  		<col width="100"/>
				  		<col width="240"/>
				  		<col width="100"/>
				  		<col />
				  	</colgroup>
			<%	for (int i = 0; i < enjoyList.size(); i++) { %>
                  <tr>
                    <th align="center" class="customer_bg">상품명</th>
                    <td colspan="3" class="customer_bg2">
                    	<%= enjoyList.get("enjoy_name",i) %>
						/
						<%= enjoyList.get("price_name",i) %>
					</td>
                  </tr>
	              <tr>
	                <td colspan="4" class="customer_line_01"></td>
	              </tr>
                  <tr>
                    <th align="center" class="customer_bg">여행일정</th>
                    <td class="customer_bg2"><%= StringUtil.toDate(enjoyList.get("start_dt",i),".") %></td>
                    <th align="center" class="customer_bg">여행인원</th>
                    <td class="customer_bg2">
                    	성인 : <%= enjoyList.get("adult_count",i) %>명
						소아 : <%= enjoyList.get("child_count",i) %>명
						유아 : <%= enjoyList.get("baby_count",i) %>명
					</td>
                  </tr>
	              <tr>
	                <td colspan="4" height="1" bgcolor="#999999"></td>
	              </tr>
        	<%	} %>
                </table></td>
              </tr>
              <tr>
              	<td align="right" style="padding-top:10px"><table width="163" border="0" cellspacing="0" cellpadding="0">
              	  <tr>
              	    <td><a href="#nohref" onclick="fnAddEnjoy()"><img src="../images/sub/btn_add.gif" alt="상품추가" width="80" height="24" /></a></td>
              	  </tr>
            	  </table></td>
              </tr>
              <!--선택관광 끝-->
              <tr>
              	<td height="36"></td>
              </tr>
              <!--렌터카 시작-->
              <tr>
                <td height="34">
                	<img src="../images/sub/customer_02_t_003.gif" alt="렌터카" width="96" height="26" />
                </td>
              </tr>
              <tr>
                <td height="2" bgcolor="#999999"></td>
              </tr>
              <tr>
                <td><table id="carList" width="100%" border="0" cellspacing="0" cellpadding="0">
                	<colgroup>
				  		<col width="100"/>
				  		<col width="240"/>
				  		<col width="100"/>
				  		<col />
				  	</colgroup>
		<%	for (int i = 0; i < carList.size(); i++) { %>
                  <tr>
                    <th align="center" class="customer_bg">차종</th>
                    <td class="customer_bg2"><%= carList.get("car_name",i) %></td>
                    <th align="center" class="customer_bg">대여일자</th>
                    <td class="customer_bg2">
                    	<%= StringUtil.toDate(carList.get("start_dt",i),".") %>
                    	/ <%= carList.get("rent_day",i) %>일
                    </td>
                  </tr>
                  <tr>
	                <td colspan="4" bgcolor="#999999"></td>
	              </tr>
        <%	} %>
                </table></td>
              </tr>

              <tr>
              	<td align="right" style="padding-top:10px"><table width="163" border="0" cellspacing="0" cellpadding="0">
              	  <tr>
              	    <td><a href="#nohref" onclick="fnAddCar()"><img src="../images/sub/btn_add.gif" alt="상품추가" width="80" height="24" /></a></td>
              	    </tr>
            	  </table></td>
              </tr>
              <tr>
              	<td height="10"></td>
              </tr>
              <!--렌터카 끝-->

              <tr>
              	<td height="30"></td>
              </tr>
				  <!--공통사항 시작-->
				  <tr>
					<td height="34">
					<img src="../images/sub/customer_02_t_001.gif" alt="공통사항" width="96" height="26" align="absmiddle"/>
					(* 필수입력 항목입니다.)
					</td>
				  </tr>
				  <tr>
					<td height="2" bgcolor="#999999"></td>
				  </tr>
				  <tr>
					<td class="customer_line_01"></td>
				  </tr>
				  <tr>
					<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
						<colgroup>
							<col width="100"/>
							<col width="240"/>
							<col width="100"/>
							<col />
						</colgroup>
					  <tr>
						<th align="center" class="customer_bg">작성자*</th>
						<td class="customer_bg2">
							<input type="text" name="customer_name" value="<%= list.get("customer_name",0) %>" style="width:200px;" class="input2" />
						</td>
						<th align="center" class="customer_bg">연락처<span class="remark">(로밍폰)</span>*</th>
						<td class="customer_bg2"><input type="text" name="phone_no" value="<%= list.get("phone_no",0) %>" style="width:200px;" class="input2" /></td>
					  </tr>
					  <tr>
						<td colspan="4" class="customer_line_01"></td>
					  </tr>
					  <tr>
						<th align="center" class="customer_bg">이메일*</th>
						<td class="customer_bg2"><%= list.get("email_addr",0) %></td>
						<th align="center" class="customer_bg">비밀번호*</th>
						<td class="customer_bg2"><%= list.get("password_enc",0) %></td>
					  </tr>
                  <tr>
	                <td colspan="4" class="customer_line_01"></td>
	              </tr>
                </table></td>
              </tr>
	              <tr><td>
	              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                	<colgroup>
				  		<col width="100"/>
				  		<col />
				  	</colgroup>
				  	<tr>
                    <th align="center" class="customer_bg">문의사항</th>
                    <td style="padding-top:10px; padding-bottom:10px" class="customer_bg2">
						<textarea name="req_info" rows="10" cols="94" class="textarea"><%= list.get("req_info",0) %></textarea>
					</td></tr></table>
				  </tr>
              <tr>
                <td class="customer_line_01"></td>
              </tr>
              <!--공통사항 끝-->
              <tr>
	          	<td height="80" align="right">
	          		<a href="./confirmReq.jsp?pmenu_id=<%=pmenu_id%>&menu_id=<%=menu_id%>&curr_page=<%=curr_page%>"><img src="../images/sub/list_btn.gif" alt="목록보기" width="62" height="19" /></a>
				  	<a href="#nohref" onclick="fnSaveReq('U')"><img src="../images/sub/edit02.gif" border="0"></a>
				  	<a href="#nohref" onclick="fnSaveReq('D')"><img src="../images/sub/delete02.gif" border="0"></a>
				  </td>
	          </tr>
            </table>
            </form>
            </td>
          </tr>
          <!--입력폼 끝-->

          <tr>
          	<td height="80"></td>
          </tr>
        </table></td>
        <!-- 컨텐츠 끝-->
      </tr>
    </table></td>
  </tr>
  <tr>
	<%@ include file="/home/include/footer.jsp" %>
  </tr>
</table>
</body>
</html>
</html>
